package com.etc

import org.apache.kafka.clients.producer.{Callback, RecordMetadata}

/**
  * @Title:
  * @ProjectName
  * @Description:
  * @author kalista
  */


class DemoCallback (startTime : Long, message : String) extends Callback{

  override def onCompletion(metadata: RecordMetadata, e: Exception): Unit = {
    val elapsedTime = System.currentTimeMillis() - startTime
    if (metadata != null) {
      System.out.println(
        "message => (" + message + ") sent to partition(" + metadata.partition() +
          "), " +
          "offset(" + metadata.offset() + ") in " + elapsedTime + " ms")
    } else {
      e.printStackTrace()
    }
  }
}